var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList:[],
    imgData:"",
    showPage:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.setData({
      cardnumber: options.card,
      str:options.ids,
    })
    console.log(options)
    that.getInfo()
  },
  getInfo(){
    var that = this
    wx.showLoading({
      title: '加载中',
    })
    app.executeRequest(function (header) {
      wx.showLoading({
        title: '加载中',
      })
      wx.request({
        url: app.BASE_URL + '/icardHospitaled/toCreateOrder',
        header: header,
        data: {
          ids:that.data.str,
          cardNum:that.data.cardnumber
        },
        success: function (res) {
          getApp().hideLoading()
          if(res.data.data && res.data.data.isClkFreeCard){
            wx.showToast({
              title: '选择成功',
            })
            setTimeout(() => {
              wx.navigateTo({
                url: '../../pkgBak/pages/closedSociety/closedSociety',
              })
            }, 3000);
          }else{
            that.setData({
              cardnumber:res.data.data.cardInfo.cardNumber,
              address:res.data.data.cardInfo.address,
              nursingName:res.data.data.cardInfo.nursingName,
              qrcode:res.data.data.qrcode,
              totalPayPrice:res.data.data.totalPayPrice,
              cardPayDeposit:res.data.data.cardPayDeposit,
              dataList:res.data.data.selEquipments,
              showPage:true
            })
            var base64Image = that.data.qrcode // 后台返回的base64数据
            var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符''
            that.setData({
              qrcode:imgData
            })
            console.log(res, 'res.data.result')
            getApp().hideLoading();
          }
        },
        fail: function (err) {
          getApp().hideLoading();
        }
      });

    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})